import {FC} from "react";
import {QuestionTitleDefaultProps, QuestionTitlePropsType} from "./interface";
import {Typography} from "antd";

const {Title} = Typography;

const QuestionTitle: FC<QuestionTitlePropsType> = (props: QuestionTitlePropsType) => {
    const {text = '', level = 1, isCenter = false} = {...QuestionTitleDefaultProps, ...props}

    const genFontSize = (level: number) => {
        switch (level) {
            case 1:
                return 32
            case 2:
                return 24
            case 3:
                return 18
            case 4:
                return 16
            case 5:
                return 14
            default:
                return 32
        }
    }

    return (

        <>
            <Title level={level}
                   style={{
                       textAlign: isCenter ? 'center' : 'start', marginBottom: 0,
                       fontSize: `${genFontSize(level)}px`
                   }}>
                {text}
            </Title>
        </>
    )
}
export default QuestionTitle;